<?php
/*
 * @Author: 小悟空56
 * @Date: 2021-04-16 20:16:20
 * @LastEditTime: 2022-03-30 17:02:24
 * @LastEditors: 小悟空56
 * @Description: 
 * @FilePath: \copy.copy.com\app\admin\controller\Index.php
 * 白月光
 */
declare (strict_types = 1);

namespace app\admin\controller;


use app\admin\facade\Menu;
use app\Request;
use liliuwei\think\Jump;
use think\App;
use think\facade\Session;
use think\facade\View;
use app\admin\utils\Utils;
use think\facade\Cookie;

class Index
{
    use Jump;

    /**
     * @return string
     * 显示主页
     */
    public function index(Request $request)
    {
		
        event('UserLogout');
        //获取左侧菜单
        if ($request->isPost()){
            $menu =  Menu::getMenu();
            return $this->success('获取成功','',$menu);
        }
        if (is_null(get_admin_session())){
            // return $this->error('请重新登录','./login');
			$this->redirect("/admin/login"); 
        }
        View::assign('userDate',get_admin_session());
//        var_dump(Session::get('name'));
        return View::fetch();
    }


    /**
     * 欢迎界面
     */
    public function welcome(){
        // 调用/app/admin/common.php下的show
        // show();
        // var_dump(get_admin_session());
        return View::fetch('welcome');

        // return View::fetch('welcome1');
    }

    // 切换语言
    public function changeLang(Request $request){
            $lang = $request->param('lang');
            switch ($lang) {
                case 'en':
                    Cookie::set('think_lang','en-us');
                    break;
                case 'zh':
                    Cookie::set('think_lang','zh-cn');
                    break;
                default:
                    # code...
                    break;
            }
            return lay_msg(0,"成功切换",);
    }

    public function test(){
       return Menu::userTest();
    }



}
